home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2001 May / macformat_103_may_2001.iso / Shareware / Palm / Emulator 3.1 / HostControl.h next >
Encoding:
C/C++ Source or Header  |  2001-03-16  |  26.2 KB  |  916 lines  |  [TEXT/CWIE]

  1. /* -*- mode: C++; tab-width: 4 -*- */
  2. /* ===================================================================== *\
  3.     Copyright (c) 1998-2001 Palm, Inc. or its subsidiaries.
  4.     All rights reserved.
  5.  
  6.     This file is part of the Palm OS Emulator.
  7.  
  8.     This program is free software; you can redistribute it and/or modify
  9.     it under the terms of the GNU General Public License as published by
  10.     the Free Software Foundation; either version 2 of the License, or
  11.     (at your option) any later version.
  12. \* ===================================================================== */
  13.  
  14. #ifndef _HOSTCONTROL_H_
  15. #define _HOSTCONTROL_H_
  16.  
  17. #if !defined (__SYSTRAPS_H_) && !defined (__CORETRAPS_H_)
  18. #error "Please #include either <CoreTraps.h> or <SysTraps.h>, depending on what's in your Palm Includes directory."
  19. #endif
  20.  
  21.  
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25.  
  26.  
  27. /*
  28.     Set the values for selectors. Note that these values MUST be
  29.     two bytes long and have the high byte be non-zero. The reason
  30.     for this has to do with the way SysGremlins was originally
  31.     declared. It took a GremlinsSelector enumerated value. Originally,
  32.     there was only one value, and it was zero. The way the 68K compiler
  33.     works, it decides that GremlinsSelectors are only one byte long,
  34.     so a call to SysGremlins would push one byte onto the stack. Because
  35.     all values on the stack need to be word-aligned, the processor
  36.     subtracts 1 from the stack before pushing on the byte. Therefore,
  37.     the stack looks like:
  38.  
  39.             previous contents
  40.             garbage byte
  41.             selector
  42.             return address
  43.  
  44.     When the two middle bytes are read together as a word, they appear
  45.     as: <selector> * 256 + <garbage byte>.
  46.  
  47.     With this setup, we have two choices: leave the selector size at
  48.     one byte and limit ourselves to 256 functions, or define the selector
  49.     to be a two byte value, with the first 256 values (all those with 0x00
  50.     in the upper byte) to be GremlinIsOn. The latter sounds preferable, so
  51.     we start the new selectors at 0x0100.
  52. */
  53.  
  54.  
  55.     // Host information selectors
  56.  
  57. #define hostSelectorGetHostVersion            0x0100
  58. #define hostSelectorGetHostID                0x0101
  59. #define hostSelectorGetHostPlatform            0x0102
  60. #define hostSelectorIsSelectorImplemented    0x0103
  61. #define hostSelectorGestalt                    0x0104
  62. #define hostSelectorIsCallingTrap            0x0105
  63.  
  64.  
  65.     // Profiler selectors
  66.  
  67. #define hostSelectorProfileInit                0x0200
  68. #define hostSelectorProfileStart            0x0201
  69. #define hostSelectorProfileStop                0x0202
  70. #define hostSelectorProfileDump                0x0203
  71. #define hostSelectorProfileCleanup            0x0204
  72. #define hostSelectorProfileDetailFn            0x0205
  73. #define hostSelectorProfileGetCycles        0x0206
  74.  
  75.  
  76.     // Std C Library wrapper selectors
  77.  
  78. #define hostSelectorErrNo                    0x0300
  79.  
  80. #define hostSelectorFClose                    0x0301
  81. #define hostSelectorFEOF                    0x0302
  82. #define hostSelectorFError                    0x0303
  83. #define hostSelectorFFlush                    0x0304
  84. #define hostSelectorFGetC                    0x0305
  85. #define hostSelectorFGetPos                    0x0306
  86. #define hostSelectorFGetS                    0x0307
  87. #define hostSelectorFOpen                    0x0308
  88. #define hostSelectorFPrintF                    0x0309        /* Floating point not yet supported in Poser */
  89. #define hostSelectorFPutC                    0x030A
  90. #define hostSelectorFPutS                    0x030B
  91. #define hostSelectorFRead                    0x030C
  92. #define hostSelectorRemove                    0x030D
  93. #define hostSelectorRename                    0x030E
  94. #define hostSelectorFReopen                    0x030F        /* Not yet implemented in Poser */
  95. #define hostSelectorFScanF                    0x0310        /* Not yet implemented */
  96. #define hostSelectorFSeek                    0x0311
  97. #define hostSelectorFSetPos                    0x0312
  98. #define hostSelectorFTell                    0x0313
  99. #define hostSelectorFWrite                    0x0314
  100. #define hostSelectorTmpFile                    0x0315
  101. #define hostSelectorTmpNam                    0x0316
  102.  
  103. #define hostSelectorGetEnv                    0x0317
  104.  
  105. #define hostSelectorMalloc                    0x0318
  106. #define hostSelectorRealloc                    0x0319
  107. #define hostSelectorFree                    0x031A
  108.  
  109.     // time.h wrappers
  110. #define hostSelectorAscTime                    0x0370
  111. #define hostSelectorClock                    0x0371
  112. #define hostSelectorCTime                    0x0372
  113. // #define hostSelectorDiffTime                0x0373
  114. #define hostSelectorGMTime                    0x0374
  115. #define hostSelectorLocalTime                0x0375
  116. #define hostSelectorMkTime                    0x0376
  117. #define hostSelectorStrFTime                0x0377
  118. #define hostSelectorTime                    0x0378
  119.  
  120.     // dirent.h wrappers
  121. #define hostSelectorOpenDir                    0x0380
  122. #define hostSelectorReadDir                    0x0381
  123. // #define hostSelectorRewindDir                0x0382
  124. #define hostSelectorCloseDir                0x0383
  125. // #define hostSelectorTellDir                    0x0384
  126. // #define hostSelectorSeekDir                    0x0385
  127. // #define hostSelectorScanDir                    0x0386
  128.  
  129.     // fcntl.h wrappers
  130. // #define hostSelectorOpen                    0x0386
  131. // #define hostSelectorCreat                    0x0388
  132. // #define hostSelectorFcntl                    0x0389
  133.  
  134.     // unistd.h wrappers
  135. // #define hostSelectorAccess                    0x038A
  136. // #define hostSelectorChDir                    0x038B
  137. // #define hostSelectorClose                    0x038C
  138. // #define hostSelectorDup                        0x038D
  139. // #define hostSelectorDup2                    0x038E
  140. // #define hostSelectorGetCwd                    0x038F
  141. // #define hostSelectorIsATTY                    0x0390
  142. // #define hostSelectorLink                    0x0391
  143. // #define hostSelectorLSeek                    0x0392
  144. // #define hostSelectorRead                    0x0393
  145. #define hostSelectorRmDir                    0x0394
  146. // #define hostSelectorTTYName                    0x0395
  147. // #define hostSelectorUnlink                    0x0396
  148. // #define hostSelectorWrite                    0x0397
  149.  
  150. // #define hostSelectorFChDir                    0x0398
  151. // #define hostSelectorFChMod                    0x0399
  152. // #define hostSelectorFileNo                    0X039A
  153. // #define hostSelectorFSync                    0x039B
  154. // #define hostSelectorFTruncate                0x039C
  155. // #define hostSelectorGetHostName                0x039D
  156. // #define hostSelectorGetWD                    0x039E
  157. // #define hostSelectorMkSTemp                    0x039F
  158. // #define hostSelectorMkTemp                    0x03A0
  159. // #define hostSelectorRe_Comp                    0x03A1
  160. // #define hostSelectorRe_Exec                    0x03A2
  161. // #define hostSelectorReadLink                0x03A3
  162. // #define hostSelectorSetHostName                0x03A4
  163. // #define hostSelectorSymLink                    0x03A5
  164. // #define hostSelectorSync                    0x03A6
  165. #define hostSelectorTruncate                0x03A7
  166.  
  167.     // sys/stat.h wrappers
  168. // #define hostSelectorChMod                    0x03A8
  169. // #define hostSelectorFStat                    0x03A9
  170. #define hostSelectorMkDir                    0x03AA
  171. #define hostSelectorStat                    0x03AB
  172. // #define hostSelectorLStat                    0x03AC
  173.  
  174.     // sys/time.h wrappers
  175. // #define hostSelectorGetTimeOfDay            0x03AD
  176. #define hostSelectorUTime                    0x03AE
  177.  
  178.     // DOS attr 
  179. #define hostSelectorGetFileAttr                0x03AF
  180. #define hostSelectorSetFileAttr                0x03B0
  181.  
  182.     // Gremlin selectors
  183.  
  184. #define hostSelectorGremlinIsRunning        0x0400
  185. #define hostSelectorGremlinNumber            0x0401
  186. #define hostSelectorGremlinCounter            0x0402
  187. #define hostSelectorGremlinLimit            0x0403
  188. #define hostSelectorGremlinNew                0x0404
  189.  
  190.  
  191.     // Database selectors
  192.  
  193. #define hostSelectorImportFile                0x0500
  194. #define hostSelectorExportFile                0x0501
  195. #define hostSelectorSaveScreen                0x0502
  196.  
  197. #define hostSelectorExgLibOpen                0x0580
  198. #define hostSelectorExgLibClose                0x0581
  199. #define hostSelectorExgLibSleep                0x0582
  200. #define hostSelectorExgLibWake                0x0583
  201. #define hostSelectorExgLibHandleEvent        0x0584
  202. #define hostSelectorExgLibConnect            0x0585
  203. #define hostSelectorExgLibAccept            0x0586
  204. #define hostSelectorExgLibDisconnect        0x0587
  205. #define hostSelectorExgLibPut                0x0588
  206. #define hostSelectorExgLibGet                0x0589
  207. #define hostSelectorExgLibSend                0x058A
  208. #define hostSelectorExgLibReceive            0x058B
  209. #define hostSelectorExgLibControl            0x058C
  210. #define hostSelectorExgLibRequest            0x058D
  211.  
  212.  
  213.     // Preferences selectors
  214.  
  215. #define hostSelectorGetPreference            0x0600
  216. #define hostSelectorSetPreference            0x0601
  217.  
  218.  
  219.     // Logging selectors
  220.  
  221. #define hostSelectorLogFile                    0x0700
  222. #define hostSelectorSetLogFileSize            0x0701
  223.  
  224.  
  225.     // RPC selectors
  226.  
  227. #define hostSelectorSessionCreate            0x0800        /* Not yet implemented in Poser */
  228. #define hostSelectorSessionOpen                0x0801        /* Not yet implemented in Poser */
  229. #define hostSelectorSessionClose            0x0802
  230. #define hostSelectorSessionQuit                0x0803
  231. #define hostSelectorSignalSend                0x0804
  232. #define hostSelectorSignalWait                0x0805
  233. #define hostSelectorSignalResume            0x0806
  234. #define hostSelectorSessionSave                0x0807
  235.  
  236.  
  237.     // External tracing tool support
  238.  
  239. #define hostSelectorTraceInit                0x0900
  240. #define hostSelectorTraceClose                0x0901
  241. #define hostSelectorTraceOutputT            0x0902
  242. #define hostSelectorTraceOutputTL            0x0903
  243. #define hostSelectorTraceOutputVT            0x0904
  244. #define hostSelectorTraceOutputVTL            0x0905
  245. #define hostSelectorTraceOutputB            0x0906
  246.  
  247.  
  248.     // Slot support
  249.  
  250. #define hostSelectorSlotMax                    0x0A00
  251. #define hostSelectorSlotRoot                0x0A01
  252. #define hostSelectorSlotHasCard                0x0A02
  253.  
  254.  
  255.     // File choosing support
  256.  
  257. #define hostSelectorGetFile                    0x0B00
  258. #define hostSelectorPutFile                    0x0B01
  259. #define hostSelectorGetDirectory            0x0B02
  260.  
  261. #define hostSelectorLastTrapNumber            0x0BFF
  262.  
  263.  
  264.     // * Types
  265.  
  266. typedef UInt16    HostControlSelectorType;
  267. typedef long    HostBoolType;
  268. typedef long    HostClockType;
  269. typedef long    HostErrType;
  270. typedef long    HostIDType;
  271. typedef long    HostPlatformType;
  272. typedef long    HostSignalType;
  273. typedef long    HostSizeType;
  274. typedef long    HostTimeType;
  275.  
  276.  
  277.     // * HostDIRType
  278.  
  279. struct HostDIRType
  280. {
  281.     long    _field;
  282. };
  283.  
  284. typedef struct HostDIRType HostDIRType;
  285.  
  286.  
  287.     // * HostDirEntType
  288.  
  289. #define HOST_NAME_MAX    255
  290.  
  291. struct HostDirEntType
  292. {
  293.     char    d_name[HOST_NAME_MAX + 1];
  294. };
  295.  
  296. typedef struct HostDirEntType HostDirEntType;
  297.  
  298.  
  299.     // * HostFILEType
  300.  
  301. struct HostFILEType
  302. {
  303.     long    _field;
  304. };
  305.  
  306. typedef struct HostFILEType HostFILEType;
  307.  
  308.  
  309.     // * HostGremlinInfoType
  310.  
  311. struct HostGremlinInfoType
  312. {
  313.     long        fFirstGremlin;
  314.     long        fLastGremlin;
  315.     long        fSaveFrequency;
  316.     long        fSwitchDepth;
  317.     long        fMaxDepth;
  318.     char        fAppNames[200];    // Comma-seperated list of application names
  319.                                 // to run Gremlins on.  If the string is empty,
  320.                                 // all applications are fair game.  If the string
  321.                                 // begins with a '-' (e.g., "-Address,Datebook"),
  322.                                 // then all applications named in the list are
  323.                                 // excluded instead of included.
  324. };
  325.  
  326. typedef struct HostGremlinInfoType HostGremlinInfoType;
  327.  
  328.  
  329.     // * HostStatType
  330.     //        Note that the field names here have an underscore appended to
  331.     //        them in order to differentiate them from "compatibility macros"
  332.     //        under Solaris.
  333.  
  334. struct HostStatType
  335. {
  336.     unsigned long    st_dev_;
  337.     unsigned long    st_ino_;
  338.     unsigned long    st_mode_;
  339.     unsigned long    st_nlink_;
  340.     unsigned long    st_uid_;
  341.     unsigned long    st_gid_;
  342.     unsigned long    st_rdev_;
  343.     HostTimeType    st_atime_;
  344.     HostTimeType    st_mtime_;
  345.     HostTimeType    st_ctime_;
  346.     unsigned long    st_size_;
  347.     unsigned long    st_blksize_;
  348.     unsigned long    st_blocks_;
  349.     unsigned long    st_flags_;
  350. };
  351.  
  352. typedef struct HostStatType HostStatType;
  353.  
  354.  
  355.     // * HostTmType
  356.     //        Note that the field names here have an underscore appended to
  357.     //        them for consistancy with HostStatType.
  358.  
  359. struct HostTmType
  360. {
  361.     long    tm_sec_;    /* seconds after the minute - [0,59] */
  362.     long    tm_min_;    /* minutes after the hour - [0,59] */
  363.     long    tm_hour_;    /* hours since midnight - [0,23] */
  364.     long    tm_mday_;    /* day of the month - [1,31] */
  365.     long    tm_mon_;    /* months since January - [0,11] */
  366.     long    tm_year_;    /* years since 1900 */
  367.     long    tm_wday_;    /* days since Sunday - [0,6] */
  368.     long    tm_yday_;    /* days since January 1 - [0,365] */
  369.     long    tm_isdst_;    /* daylight savings time flag */
  370. };
  371.  
  372. typedef struct HostTmType HostTmType;
  373.  
  374.  
  375.     // * HostUTimeType
  376.     //        Note that the field names here have an underscore appended to
  377.     //        them for consistancy with HostStatType.
  378.  
  379. struct HostUTimeType
  380. {
  381.     HostTimeType    crtime_;    /* creation time */
  382.     HostTimeType    actime_;    /* access time */
  383.     HostTimeType    modtime_;    /* modification time */
  384. };
  385.  
  386. typedef struct HostUTimeType HostUTimeType;
  387.  
  388.  
  389.     // * Backward compatiblity
  390.  
  391. typedef HostControlSelectorType    HostControlTrapNumber;
  392. typedef HostBoolType            HostBool;
  393. typedef HostErrType                HostErr;
  394. typedef HostIDType                HostID;
  395. typedef HostPlatformType        HostPlatform;
  396. typedef HostSignalType            HostSignal;
  397. typedef HostFILEType            HostFILE;
  398.  
  399.  
  400.  
  401. #ifndef hostErrorClass
  402.     #define    hostErrorClass                0x1C00    // Host Control Manager
  403. #else
  404.     #if hostErrorClass != 0x1C00
  405.         #error "You cannot change hostErrorClass without telling us."
  406.     #endif
  407. #endif
  408.  
  409. enum    // HostErrType values
  410. {
  411.     hostErrNone = 0,
  412.  
  413.     hostErrBase = hostErrorClass,
  414.  
  415.     hostErrUnknownGestaltSelector,
  416.     hostErrDiskError,
  417.     hostErrOutOfMemory,
  418.     hostErrMemReadOutOfRange,
  419.     hostErrMemWriteOutOfRange,
  420.     hostErrMemInvalidPtr,
  421.     hostErrInvalidParameter,
  422.     hostErrTimeout,
  423.     hostErrInvalidDeviceType,
  424.     hostErrInvalidRAMSize,
  425.     hostErrFileNotFound,
  426.     hostErrRPCCall,                // Issued if the following functions are not called remotely:
  427.                                 //        HostSessionCreate
  428.                                 //        HostSessionOpen
  429.                                 //        HostSessionClose
  430.                                 //        HostSessionQuit
  431.                                 //        HostSignalWait
  432.                                 //        HostSignalResume
  433.     hostErrSessionRunning,        // Issued by HostSessionCreate, HostSessionOpen, and
  434.                                 // HostSessionQuit if a session is running.
  435.     hostErrSessionNotRunning,    // Issued by HostSessionClose or HostSessionSave if no session is running.
  436.     hostErrNoSignalWaiters,        // Issued by HostSendSignal if no one's waiting for a signal.
  437.     hostErrSessionNotPaused,    // Issued when HostSignalResume, but the session was not
  438.                                 // halted from a HostSignalSend call.
  439.     
  440.     hostErrPermissions,
  441.     hostErrFileNameTooLong,
  442.     hostErrNotADirectory,
  443.     hostErrTooManyFiles,
  444.     hostErrFileTooBig,
  445.     hostErrReadOnlyFS,
  446.     hostErrIsDirectory,
  447.     hostErrExists,
  448.     hostErrOpNotAvailable,
  449.     hostErrDirNotEmpty,
  450.     hostErrDiskFull,
  451.     hostErrProfilingNotReady,
  452.     hostErrUnknownError
  453. };
  454.  
  455.  
  456. enum    // HostIDType values
  457. {
  458.     hostIDPalmOS,            // The plastic thingy
  459.     hostIDPalmOSEmulator,    // The Copilot thingy
  460.     hostIDPalmOSSimulator    // The Mac libraries you link with thingy
  461. };
  462.  
  463.  
  464. enum    // HostPlatformType values
  465. {
  466.     hostPlatformPalmOS,
  467.     hostPlatformWindows,
  468.     hostPlatformMacintosh,
  469.     hostPlatformUnix
  470. };
  471.  
  472. enum    // HostSignalType values
  473. {
  474.     hostSignalReserved,
  475.     hostSignalIdle,
  476.     hostSignalQuit,
  477. #if 0
  478.     // (Proposed...not supported yet)
  479.     hostSignalSessionStarted,
  480.     hostSignalSessionStopped,
  481.     hostSignalHordeStarted,
  482.     hostSignalGremlinStarted,
  483.     hostSignalGremlinSuspended,
  484.     hostSignalGremlinResumed,
  485.     hostSignalGremlinStopped,
  486.     hostSignalHordeStopped,
  487. #endif
  488.     hostSignalUser    = 0x40000000    // User-defined values start here and go up.
  489. };
  490.  
  491. enum    // HostGet/SetFileAttr flags, matching EmFileAttr flags
  492. {
  493.     hostFileAttrReadOnly = 1,
  494.     hostFileAttrHidden = 2,
  495.     hostFileAttrSystem = 4
  496. };
  497.  
  498. // Use these to call FtrGet to see if you're running under the
  499. // Palm OS Emulator.  If not, FtrGet will return ftrErrNoSuchFeature.
  500.  
  501. #define kPalmOSEmulatorFeatureCreator    ('pose')
  502. #define kPalmOSEmulatorFeatureNumber    (0)
  503.  
  504.  
  505. // Define this, since SysTraps.h doesn't have it.
  506.  
  507. #ifdef __SYSTRAPS_H_
  508. #define sysTrapHostControl sysTrapSysGremlins
  509. #endif
  510.  
  511.  
  512. // Define HOST_TRAP
  513.  
  514. #if defined (_SYSTEM_API)
  515.  
  516. #define HOST_TRAP(selector)    \
  517.     _SYSTEM_API(_CALL_WITH_16BIT_SELECTOR)(_SYSTEM_TABLE, sysTrapHostControl, selector)
  518.  
  519. #else
  520.  
  521. #define HOST_TRAP(selector)                                                    \
  522.     FIVEWORD_INLINE(                                                        \
  523.         0x3F3C, selector,                    /* MOVE.W #selector, -(A7)    */    \
  524.         m68kTrapInstr + sysDispatchTrapNum,    /* TRAP $F                    */    \
  525.         sysTrapHostControl,                    /* sysTrapHostControl        */    \
  526.         0x544F)                                /* ADD.Q #2, A7                */ 
  527. #endif
  528.  
  529.  
  530. /* ==================================================================== */
  531. /* Host environment-related calls                                        */
  532. /* ==================================================================== */
  533.  
  534. long                HostGetHostVersion(void)
  535.                         HOST_TRAP(hostSelectorGetHostVersion);
  536.  
  537. HostIDType            HostGetHostID(void)
  538.                         HOST_TRAP(hostSelectorGetHostID);
  539.  
  540. HostPlatformType    HostGetHostPlatform(void)
  541.                         HOST_TRAP(hostSelectorGetHostPlatform);
  542.  
  543. HostBoolType        HostIsSelectorImplemented(long selector)
  544.                         HOST_TRAP(hostSelectorIsSelectorImplemented);
  545.  
  546. HostErrType            HostGestalt(long gestSel, long* response)
  547.                         HOST_TRAP(hostSelectorGestalt);
  548.  
  549. HostBoolType        HostIsCallingTrap(void)
  550.                         HOST_TRAP(hostSelectorIsCallingTrap);
  551.  
  552.  
  553. /* ==================================================================== */
  554. /* Profiling-related calls                                                */
  555. /* ==================================================================== */
  556.  
  557. HostErrType            HostProfileInit(long maxCalls, long maxDepth)
  558.                         HOST_TRAP(hostSelectorProfileInit);
  559.  
  560. HostErrType            HostProfileDetailFn(void* addr, HostBoolType logDetails)
  561.                         HOST_TRAP(hostSelectorProfileDetailFn);
  562.  
  563. HostErrType            HostProfileStart(void)
  564.                         HOST_TRAP(hostSelectorProfileStart);
  565.  
  566. HostErrType            HostProfileStop(void)
  567.                         HOST_TRAP(hostSelectorProfileStop);
  568.  
  569. HostErrType            HostProfileDump(const char* filename)
  570.                         HOST_TRAP(hostSelectorProfileDump);
  571.  
  572. HostErrType            HostProfileCleanup(void)
  573.                         HOST_TRAP(hostSelectorProfileCleanup);
  574.  
  575. long                HostProfileGetCycles(void)
  576.                         HOST_TRAP(hostSelectorProfileGetCycles);
  577.  
  578.  
  579. /* ==================================================================== */
  580. /* Std C Library-related calls                                            */
  581. /* ==================================================================== */
  582.  
  583. long                HostErrNo(void)
  584.                         HOST_TRAP(hostSelectorErrNo);
  585.  
  586.  
  587. long                HostFClose(HostFILEType* f)
  588.                         HOST_TRAP(hostSelectorFClose);
  589.  
  590. long                HostFEOF(HostFILEType* f)
  591.                         HOST_TRAP(hostSelectorFEOF);
  592.  
  593. long                HostFError(HostFILEType* f)
  594.                         HOST_TRAP(hostSelectorFError);
  595.  
  596. long                HostFFlush(HostFILEType* f)
  597.                         HOST_TRAP(hostSelectorFFlush);
  598.  
  599. long                HostFGetC(HostFILEType* f)
  600.                         HOST_TRAP(hostSelectorFGetC);
  601.  
  602. long                HostFGetPos(HostFILEType* f, long* posP)
  603.                         HOST_TRAP(hostSelectorFGetPos);
  604.  
  605. char*                HostFGetS(char* s, long n, HostFILEType* f)
  606.                         HOST_TRAP(hostSelectorFGetS);
  607.  
  608. HostFILEType*        HostFOpen(const char* name, const char* mode)
  609.                         HOST_TRAP(hostSelectorFOpen);
  610.  
  611. long                HostFPrintF(HostFILEType* f, const char* fmt, ...)
  612.                         HOST_TRAP(hostSelectorFPrintF);
  613.  
  614. long                HostFPutC(long c, HostFILEType* f)
  615.                         HOST_TRAP(hostSelectorFPutC);
  616.  
  617. long                HostFPutS(const char* s, HostFILEType* f)
  618.                         HOST_TRAP(hostSelectorFPutS);
  619.  
  620. long                HostFRead(void* buffer, long size, long count, HostFILEType* f)
  621.                         HOST_TRAP(hostSelectorFRead);
  622.  
  623. long                HostRemove(const char* name)
  624.                         HOST_TRAP(hostSelectorRemove);
  625.  
  626. long                HostRename(const char* oldName, const char* newName)
  627.                         HOST_TRAP(hostSelectorRename);
  628.  
  629. HostFILEType*        HostFReopen(const char* name, const char* mode, HostFILEType* f)
  630.                         HOST_TRAP(hostSelectorFReopen);
  631.  
  632. long                HostFScanF(HostFILEType* f, const char* fmt, ...)
  633.                         HOST_TRAP(hostSelectorFScanF);
  634.  
  635. long                HostFSeek(HostFILEType* f, long offset, long origin)
  636.                         HOST_TRAP(hostSelectorFSeek);
  637.  
  638. long                HostFSetPos(HostFILEType* f, long* pos)
  639.                         HOST_TRAP(hostSelectorFSetPos);
  640.  
  641. long                HostFTell(HostFILEType* f)
  642.                         HOST_TRAP(hostSelectorFTell);
  643.  
  644. long                HostFWrite(const void* buffer, long size, long count, HostFILEType* f)
  645.                         HOST_TRAP(hostSelectorFWrite);
  646.  
  647. HostFILEType*        HostTmpFile(void)
  648.                         HOST_TRAP(hostSelectorTmpFile);
  649.  
  650. char*                HostTmpNam(char* name)
  651.                         HOST_TRAP(hostSelectorTmpNam);
  652.  
  653. char*                HostGetEnv(const char*)
  654.                         HOST_TRAP(hostSelectorGetEnv);
  655.  
  656.  
  657. void*                HostMalloc(long size)
  658.                         HOST_TRAP(hostSelectorMalloc);
  659.  
  660. void*                HostRealloc(void* p, long size)
  661.                         HOST_TRAP(hostSelectorRealloc);
  662.  
  663. void                HostFree(void* p)
  664.                         HOST_TRAP(hostSelectorFree);
  665.  
  666.  
  667. char*                HostAscTime(const HostTmType*)
  668.                         HOST_TRAP(hostSelectorAscTime);
  669.  
  670. char*                HostCTime(const HostTimeType*)
  671.                         HOST_TRAP(hostSelectorCTime);
  672.  
  673. HostClockType        HostClock(void)
  674.                         HOST_TRAP(hostSelectorClock);
  675.  
  676. //double                HostDiffTime(HostTimeType, HostTimeType)
  677. //                        HOST_TRAP(hostSelectorDiffTime);
  678.  
  679. HostTmType*            HostGMTime(const HostTimeType*)
  680.                         HOST_TRAP(hostSelectorGMTime);
  681.  
  682. HostTmType*            HostLocalTime(const HostTimeType*)
  683.                         HOST_TRAP(hostSelectorLocalTime);
  684.  
  685. HostTimeType        HostMkTime(HostTmType*)
  686.                         HOST_TRAP(hostSelectorMkTime);
  687.  
  688. HostSizeType        HostStrFTime(char*, HostSizeType, const char*, const HostTmType*)
  689.                         HOST_TRAP(hostSelectorStrFTime);
  690.  
  691. HostTimeType        HostTime(HostTimeType*)
  692.                         HOST_TRAP(hostSelectorTime);
  693.  
  694.  
  695. long                HostMkDir(const char*)
  696.                         HOST_TRAP(hostSelectorMkDir);
  697.  
  698. long                HostRmDir(const char*)
  699.                         HOST_TRAP(hostSelectorRmDir);
  700.  
  701. HostDIRType*        HostOpenDir(const char*)
  702.                         HOST_TRAP(hostSelectorOpenDir);
  703.  
  704. HostDirEntType*        HostReadDir(HostDIRType*)
  705.                         HOST_TRAP(hostSelectorReadDir);
  706.  
  707. long                HostCloseDir(HostDIRType*)
  708.                         HOST_TRAP(hostSelectorCloseDir);
  709.  
  710.  
  711. long                HostStat(const char*, HostStatType*)
  712.                         HOST_TRAP(hostSelectorStat);
  713.  
  714. long                HostTruncate(const char*, long)
  715.                         HOST_TRAP(hostSelectorTruncate);
  716.  
  717.  
  718. long                HostUTime (const char*, HostUTimeType*)
  719.                         HOST_TRAP(hostSelectorUTime);
  720.  
  721. long                HostGetFileAttr(const char*, long*)
  722.                         HOST_TRAP(hostSelectorGetFileAttr);
  723.  
  724. long                HostSetFileAttr(const char*, long)
  725.                         HOST_TRAP(hostSelectorSetFileAttr);
  726.  
  727.  
  728. /* ==================================================================== */
  729. /* Gremlin-related calls                                                */
  730. /* ==================================================================== */
  731.  
  732. HostBoolType        HostGremlinIsRunning(void)
  733.                         HOST_TRAP(hostSelectorGremlinIsRunning);
  734.  
  735. long                HostGremlinNumber(void)
  736.                         HOST_TRAP(hostSelectorGremlinNumber);
  737.  
  738. long                HostGremlinCounter(void)
  739.                         HOST_TRAP(hostSelectorGremlinCounter);
  740.  
  741. long                HostGremlinLimit(void)
  742.                         HOST_TRAP(hostSelectorGremlinLimit);
  743.  
  744. HostErrType            HostGremlinNew(const HostGremlinInfoType*)
  745.                         HOST_TRAP(hostSelectorGremlinNew);
  746.  
  747.  
  748. /* ==================================================================== */
  749. /* Import/export-related calls                                            */
  750. /* ==================================================================== */
  751.  
  752. HostErrType            HostImportFile(const char* fileName, long cardNum)
  753.                         HOST_TRAP(hostSelectorImportFile);
  754.  
  755. HostErrType            HostExportFile(const char* fileName, long cardNum, const char* dbName)
  756.                         HOST_TRAP(hostSelectorExportFile);
  757.  
  758. HostErrType            HostSaveScreen(const char* fileName)
  759.                         HOST_TRAP(hostSelectorSaveScreen);
  760.  
  761.     // These are private, internal functions.  Third party applications
  762.     // should not be calling them.
  763.  
  764. Err                    HostExgLibOpen            (UInt16 libRefNum)
  765.                         HOST_TRAP(hostSelectorExgLibOpen);
  766.  
  767. Err                    HostExgLibClose            (UInt16 libRefNum)
  768.                         HOST_TRAP(hostSelectorExgLibClose);
  769.  
  770. Err                    HostExgLibSleep            (UInt16 libRefNum)
  771.                         HOST_TRAP(hostSelectorExgLibSleep);
  772.  
  773. Err                    HostExgLibWake            (UInt16 libRefNum)
  774.                         HOST_TRAP(hostSelectorExgLibWake);
  775.  
  776. Boolean                HostExgLibHandleEvent    (UInt16 libRefNum, void* eventP)
  777.                         HOST_TRAP(hostSelectorExgLibHandleEvent);
  778.  
  779. Err                     HostExgLibConnect        (UInt16 libRefNum, void* exgSocketP)
  780.                         HOST_TRAP(hostSelectorExgLibConnect);
  781.  
  782. Err                    HostExgLibAccept        (UInt16 libRefNum, void* exgSocketP)
  783.                         HOST_TRAP(hostSelectorExgLibAccept);
  784.  
  785. Err                    HostExgLibDisconnect    (UInt16 libRefNum, void* exgSocketP,Err error)
  786.                         HOST_TRAP(hostSelectorExgLibDisconnect);
  787.  
  788. Err                    HostExgLibPut            (UInt16 libRefNum, void* exgSocketP)
  789.                         HOST_TRAP(hostSelectorExgLibPut);
  790.  
  791. Err                    HostExgLibGet            (UInt16 libRefNum, void* exgSocketP)
  792.                         HOST_TRAP(hostSelectorExgLibGet);
  793.  
  794. UInt32                 HostExgLibSend            (UInt16 libRefNum, void* exgSocketP, const void* const bufP, const UInt32 bufLen, Err* errP)
  795.                         HOST_TRAP(hostSelectorExgLibSend);
  796.  
  797. UInt32                 HostExgLibReceive        (UInt16 libRefNum, void* exgSocketP, void* bufP, const UInt32 bufSize, Err* errP)
  798.                         HOST_TRAP(hostSelectorExgLibReceive);
  799.  
  800. Err                 HostExgLibControl        (UInt16 libRefNum, UInt16 op, void* valueP, UInt16* valueLenP)
  801.                         HOST_TRAP(hostSelectorExgLibControl);
  802.  
  803. Err                 HostExgLibRequest        (UInt16 libRefNum, void* exgSocketP)
  804.                         HOST_TRAP(hostSelectorExgLibRequest);
  805.  
  806.  
  807. /* ==================================================================== */
  808. /* Preference-related calls                                                */
  809. /* ==================================================================== */
  810.  
  811. HostBoolType        HostGetPreference(const char*, char*)
  812.                         HOST_TRAP(hostSelectorGetPreference);
  813.  
  814. void                HostSetPreference(const char*, const char*)
  815.                         HOST_TRAP(hostSelectorSetPreference);
  816.  
  817.  
  818. /* ==================================================================== */
  819. /* Logging-related calls                                                */
  820. /* ==================================================================== */
  821.  
  822. HostFILEType*        HostLogFile(void)
  823.                         HOST_TRAP(hostSelectorLogFile);
  824.  
  825. void                HostSetLogFileSize(long)
  826.                         HOST_TRAP(hostSelectorSetLogFileSize);
  827.  
  828.  
  829. /* ==================================================================== */
  830. /* RPC-related calls                                                    */
  831. /* ==================================================================== */
  832.  
  833. HostErrType            HostSessionCreate(const char* device, long ramSize, const char* romPath)
  834.                         HOST_TRAP(hostSelectorSessionCreate);
  835.  
  836. HostErrType            HostSessionOpen(const char* psfFileName)
  837.                         HOST_TRAP(hostSelectorSessionOpen);
  838.  
  839. HostBoolType        HostSessionSave(const char* saveFileName)
  840.                         HOST_TRAP(hostSelectorSessionSave);
  841.  
  842. HostErrType            HostSessionClose(const char* saveFileName)
  843.                         HOST_TRAP(hostSelectorSessionClose);
  844.  
  845. HostErrType            HostSessionQuit(void)
  846.                         HOST_TRAP(hostSelectorSessionQuit);
  847.  
  848. HostErrType            HostSignalSend(HostSignalType signalNumber)
  849.                         HOST_TRAP(hostSelectorSignalSend);
  850.  
  851. HostErrType            HostSignalWait(long timeout, HostSignalType* signalNumber)
  852.                         HOST_TRAP(hostSelectorSignalWait);
  853.  
  854. HostErrType            HostSignalResume(void)
  855.                         HOST_TRAP(hostSelectorSignalResume);
  856.  
  857.  
  858. /* ==================================================================== */
  859. /* Tracing calls                                                        */
  860. /* ==================================================================== */
  861.  
  862. void                HostTraceInit(void)
  863.                         HOST_TRAP(hostSelectorTraceInit);
  864.  
  865. void                HostTraceClose(void)
  866.                         HOST_TRAP(hostSelectorTraceClose);
  867.  
  868. void                HostTraceOutputT(unsigned short, const char*, ...)
  869.                         HOST_TRAP(hostSelectorTraceOutputT);
  870.  
  871. void                HostTraceOutputTL(unsigned short, const char*, ...)
  872.                         HOST_TRAP(hostSelectorTraceOutputTL);
  873.  
  874. void                HostTraceOutputVT(unsigned short, const char*, char* /*va_list*/)
  875.                         HOST_TRAP(hostSelectorTraceOutputVT);
  876.  
  877. void                HostTraceOutputVTL(unsigned short, const char*, char* /*va_list*/)
  878.                         HOST_TRAP(hostSelectorTraceOutputVTL);
  879.  
  880. void                HostTraceOutputB(unsigned short, const void*, HostSizeType)
  881.                         HOST_TRAP(hostSelectorTraceOutputB);
  882.  
  883.  
  884. /* ==================================================================== */
  885. /* Slot related calls                                                    */
  886. /* ==================================================================== */
  887.  
  888. long                HostSlotMax(void)
  889.                         HOST_TRAP(hostSelectorSlotMax);
  890.  
  891. const char*            HostSlotRoot(long slotNo)
  892.                         HOST_TRAP(hostSelectorSlotRoot);
  893.  
  894. HostBoolType        HostSlotHasCard(long slotNo)
  895.                         HOST_TRAP(hostSelectorSlotHasCard);
  896.  
  897.  
  898. /* ==================================================================== */
  899. /* File Choosing support                                                */
  900. /* ==================================================================== */
  901.  
  902. const char*            HostGetFile(const char* prompt, const char* defaultDir)
  903.                         HOST_TRAP(hostSelectorGetFile);
  904.  
  905. const char*            HostPutFile(const char* prompt, const char* defaultDir, const char* defaultName)
  906.                         HOST_TRAP(hostSelectorPutFile);
  907.  
  908. const char*            HostGetDirectory(const char* prompt, const char* defaultDir)
  909.                         HOST_TRAP(hostSelectorGetDirectory);
  910.  
  911. #ifdef __cplusplus 
  912. }
  913. #endif
  914.  
  915. #endif /* _HOSTCONTROL_H_ */
  916.